﻿
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_AlertsReminder_AlertStatus]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[AlertsReminder] DROP CONSTRAINT [DF_AlertsReminder_AlertStatus]
END

GO

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[AlertsReminder]    Script Date: 09/06/2014 00:25:45 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AlertsReminder]') AND type in (N'U'))
DROP TABLE [dbo].[AlertsReminder]
GO

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientVisits]    Script Date: 09/06/2014 00:26:28 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PatientVisits](
	[PatientID] [bigint] NOT NULL,
	[VisitID] [smallint] NOT NULL,
	[VisitDataTime] [smalldatetime] NOT NULL,
	[ConsultingDoc] [int] NOT NULL,
	[ConsultationRoom] [int] NULL,
	[VisitStatus] [int] NULL,
	[CompalinedDiseases] [int] NOT NULL,
	[FollowUpID] [int] NULL,
	[VisitNote] [varchar](500) NULL,
 CONSTRAINT [PK_PatientVisits] PRIMARY KEY CLUSTERED 
(
	[PatientID] ASC,
	[VisitID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PatientVisits]  WITH CHECK ADD  CONSTRAINT [FK_PatientVisits_DiseasesMaster] FOREIGN KEY([CompalinedDiseases])
REFERENCES [dbo].[DiseasesMaster] ([DID])
GO

ALTER TABLE [dbo].[PatientVisits] CHECK CONSTRAINT [FK_PatientVisits_DiseasesMaster]
GO

ALTER TABLE [dbo].[PatientVisits]  WITH CHECK ADD  CONSTRAINT [FK_PatientVisits_DoctorMaster] FOREIGN KEY([ConsultingDoc])
REFERENCES [dbo].[DoctorMaster] ([DrID])
GO

ALTER TABLE [dbo].[PatientVisits] CHECK CONSTRAINT [FK_PatientVisits_DoctorMaster]
GO

ALTER TABLE [dbo].[PatientVisits]  WITH CHECK ADD  CONSTRAINT [FK_PatientVisits_LookupsMaster] FOREIGN KEY([VisitStatus])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientVisits] CHECK CONSTRAINT [FK_PatientVisits_LookupsMaster]
GO

ALTER TABLE [dbo].[PatientVisits]  WITH CHECK ADD  CONSTRAINT [FK_PatientVisits_PatientFollowUp] FOREIGN KEY([FollowUpID])
REFERENCES [dbo].[PatientFollowUp] ([FollowUpID])
GO

ALTER TABLE [dbo].[PatientVisits] CHECK CONSTRAINT [FK_PatientVisits_PatientFollowUp]
GO

ALTER TABLE [dbo].[PatientVisits]  WITH CHECK ADD  CONSTRAINT [FK_PatientVisits_PatientRegistration] FOREIGN KEY([PatientID])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
GO

ALTER TABLE [dbo].[PatientVisits] CHECK CONSTRAINT [FK_PatientVisits_PatientRegistration]
GO

ALTER TABLE [dbo].[PatientVisits]  WITH CHECK ADD  CONSTRAINT [FK_PatientVisits_RoomMaster] FOREIGN KEY([ConsultationRoom])
REFERENCES [dbo].[RoomMaster] ([RoomID])
GO

ALTER TABLE [dbo].[PatientVisits] CHECK CONSTRAINT [FK_PatientVisits_RoomMaster]
GO


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientRegistration]    Script Date: 09/06/2014 00:26:42 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PatientRegistration](
	[PatientId] [bigint] IDENTITY(1,1) NOT NULL,
	[FirstName] [varchar](100) NOT NULL,
	[LastName] [varchar](100) NOT NULL,
	[SurName] [varchar](50) NULL,
	[Gender] [bit] NOT NULL,
	[Address] [varchar](200) NULL,
	[Telephone No] [varchar](50) NULL,
	[Mobile No] [varchar](50) NULL,
	[Contact Person] [varchar](100) NULL,
	[Email] [varchar](50) NULL,
	[Remarks] [varchar](200) NULL,
	[PatientType] [int] NOT NULL,
	[RegistrationDate] [smalldatetime] NOT NULL,
	[RefByDoc] [varchar](50) NULL,
	[DOB] [date] NULL,
	[Age] [numeric](5, 2) NOT NULL,
	[Occupation] [varchar](50) NULL,
	[AssignedDr] [int] NULL,
	[MaritalStatus] [int] NULL,
	[Language] [int] NULL,
	[Confidential] [int] NULL,
	[Religion] [int] NULL,
	[BloodGroup] [int] NULL,
	[SiblingBrother] [tinyint] NULL,
	[SiblingSister] [tinyint] NULL,
	[ChildBoys] [tinyint] NULL,
	[ChildGirl] [tinyint] NULL,
	[Diet] [int] NULL,
	[CreatedBy] [int] NOT NULL,
	[CreatedDateTime] [smalldatetime] NOT NULL,
	[UpdatedBy] [int] NULL,
	[UpdatedDateTime] [smalldatetime] NULL,
	[Image] [varbinary](max) NULL,
 CONSTRAINT [PK_PatientRegistration] PRIMARY KEY CLUSTERED 
(
	[PatientId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1 - Male, 0 - Female' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'PatientRegistration', @level2type=N'COLUMN',@level2name=N'Gender'
GO

ALTER TABLE [dbo].[PatientRegistration]  WITH CHECK ADD  CONSTRAINT [FK_PatientRegistration_LookupsMaster] FOREIGN KEY([MaritalStatus])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientRegistration] CHECK CONSTRAINT [FK_PatientRegistration_LookupsMaster]
GO

ALTER TABLE [dbo].[PatientRegistration]  WITH CHECK ADD  CONSTRAINT [FK_PatientRegistration_LookupsMaster1] FOREIGN KEY([Language])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientRegistration] CHECK CONSTRAINT [FK_PatientRegistration_LookupsMaster1]
GO

ALTER TABLE [dbo].[PatientRegistration]  WITH CHECK ADD  CONSTRAINT [FK_PatientRegistration_LookupsMaster2] FOREIGN KEY([Confidential])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientRegistration] CHECK CONSTRAINT [FK_PatientRegistration_LookupsMaster2]
GO

ALTER TABLE [dbo].[PatientRegistration]  WITH CHECK ADD  CONSTRAINT [FK_PatientRegistration_LookupsMaster3] FOREIGN KEY([Religion])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientRegistration] CHECK CONSTRAINT [FK_PatientRegistration_LookupsMaster3]
GO

ALTER TABLE [dbo].[PatientRegistration]  WITH CHECK ADD  CONSTRAINT [FK_PatientRegistration_LookupsMaster4] FOREIGN KEY([BloodGroup])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientRegistration] CHECK CONSTRAINT [FK_PatientRegistration_LookupsMaster4]
GO

ALTER TABLE [dbo].[PatientRegistration]  WITH CHECK ADD  CONSTRAINT [FK_PatientRegistration_LookupsMaster5] FOREIGN KEY([Diet])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientRegistration] CHECK CONSTRAINT [FK_PatientRegistration_LookupsMaster5]
GO

ALTER TABLE [dbo].[PatientRegistration] ADD  CONSTRAINT [DF_PatientRegistration_Gender]  DEFAULT ((0)) FOR [Gender]
GO

ALTER TABLE [dbo].[PatientRegistration] ADD  CONSTRAINT [DF_PatientRegistration_RegistrationDate]  DEFAULT (getdate()) FOR [RegistrationDate]
GO

ALTER TABLE [dbo].[PatientRegistration] ADD  CONSTRAINT [DF_PatientRegistration_CreatedDateTime]  DEFAULT (getdate()) FOR [CreatedDateTime]
GO

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[BillingMaster]    Script Date: 09/06/2014 00:26:54 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[BillingMaster](
	[BillID] [bigint] IDENTITY(1,1) NOT NULL,
	[BillDate] [smalldatetime] NOT NULL,
	[PatientID] [int] NOT NULL,
	[Remarks] [varchar](500) NULL,
	[GrAmt] [numeric](18, 2) NULL,
	[OtherCharges] [numeric](18, 2) NULL,
	[NetAmt] [numeric](18, 2) NULL,
	[BranchID] [tinyint] NULL,
	[CreatedBy] [int] NOT NULL,
	[CreatedDateTime] [smalldatetime] NOT NULL,
	[UpdatedBy] [int] NULL,
	[UpdatedDateTime] [smalldatetime] NULL,
	[BillCategory] [int] NULL,
 CONSTRAINT [PK_tbl_MyBill] PRIMARY KEY CLUSTERED 
(
	[BillID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[BillingMaster] ADD  CONSTRAINT [DF_BillingMaster_CreatedDateTime]  DEFAULT (getdate()) FOR [CreatedDateTime]
GO


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientProblems]    Script Date: 09/06/2014 00:28:24 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PatientProblems](
	[PatientId] [bigint] NOT NULL,
	[ProblemID] [smallint] NOT NULL,
	[VisitID] [smallint] NOT NULL,
	[ReportedDateTime] [date] NOT NULL,
	[ReportedDr] [int] NULL,
	[Problem] [int] NOT NULL,
	[Period] [float] NULL,
	[ProblemPeriod] [int] NULL,
	[ProblemTiming] [int] NULL,
	[ProblemDuration] [int] NULL,
	[ProblemLocation] [int] NULL,
	[Severity] [int] NULL,
	[Comments] [varchar](500) NULL,
 CONSTRAINT [PK_PatientProblems] PRIMARY KEY CLUSTERED 
(
	[PatientId] ASC,
	[ProblemID] ASC,
	[VisitID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PatientProblems]  WITH CHECK ADD  CONSTRAINT [FK_PatientProblems_DoctorMaster] FOREIGN KEY([ReportedDr])
REFERENCES [dbo].[DoctorMaster] ([DrID])
GO

ALTER TABLE [dbo].[PatientProblems] CHECK CONSTRAINT [FK_PatientProblems_DoctorMaster]
GO

ALTER TABLE [dbo].[PatientProblems]  WITH CHECK ADD  CONSTRAINT [FK_PatientProblems_LookupsMaster] FOREIGN KEY([ProblemDuration])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientProblems] CHECK CONSTRAINT [FK_PatientProblems_LookupsMaster]
GO

ALTER TABLE [dbo].[PatientProblems]  WITH CHECK ADD  CONSTRAINT [FK_PatientProblems_LookupsMaster1] FOREIGN KEY([ProblemLocation])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientProblems] CHECK CONSTRAINT [FK_PatientProblems_LookupsMaster1]
GO

ALTER TABLE [dbo].[PatientProblems]  WITH CHECK ADD  CONSTRAINT [FK_PatientProblems_LookupsMaster2] FOREIGN KEY([ProblemPeriod])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientProblems] CHECK CONSTRAINT [FK_PatientProblems_LookupsMaster2]
GO

ALTER TABLE [dbo].[PatientProblems]  WITH CHECK ADD  CONSTRAINT [FK_PatientProblems_LookupsMaster3] FOREIGN KEY([ProblemTiming])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientProblems] CHECK CONSTRAINT [FK_PatientProblems_LookupsMaster3]
GO

ALTER TABLE [dbo].[PatientProblems]  WITH CHECK ADD  CONSTRAINT [FK_PatientProblems_LookupsMaster4] FOREIGN KEY([Severity])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientProblems] CHECK CONSTRAINT [FK_PatientProblems_LookupsMaster4]
GO

ALTER TABLE [dbo].[PatientProblems]  WITH CHECK ADD  CONSTRAINT [FK_PatientProblems_PatientRegistration] FOREIGN KEY([PatientId])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
GO

ALTER TABLE [dbo].[PatientProblems] CHECK CONSTRAINT [FK_PatientProblems_PatientRegistration]
GO

ALTER TABLE [dbo].[PatientProblems]  WITH CHECK ADD  CONSTRAINT [FK_PatientProblems_PatientVisits] FOREIGN KEY([PatientId], [VisitID])
REFERENCES [dbo].[PatientVisits] ([PatientID], [VisitID])
GO

ALTER TABLE [dbo].[PatientProblems] CHECK CONSTRAINT [FK_PatientProblems_PatientVisits]
GO

ALTER TABLE [dbo].[PatientProblems]  WITH CHECK ADD  CONSTRAINT [FK_PatientProblems_Problems] FOREIGN KEY([Problem])
REFERENCES [dbo].[Problems] ([ProblemID])
GO

ALTER TABLE [dbo].[PatientProblems] CHECK CONSTRAINT [FK_PatientProblems_Problems]
GO

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientPrescription]    Script Date: 09/06/2014 00:28:33 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PatientPrescription](
	[PatientId] [bigint] NOT NULL,
	[PrescriptionID] [smallint] NOT NULL,
	[VisitID] [smallint] NOT NULL,
	[MedicineItemID] [bigint] NOT NULL,
	[Dosage] [float] NOT NULL,
	[Frequency] [int] NULL,
	[Duaration] [float] NULL,
	[Periods] [varchar](20) NULL,
 CONSTRAINT [PK_PatientPrescription] PRIMARY KEY CLUSTERED 
(
	[PatientId] ASC,
	[PrescriptionID] ASC,
	[VisitID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PatientPrescription]  WITH CHECK ADD  CONSTRAINT [FK_PatientPrescription_ItemServiceMaster] FOREIGN KEY([MedicineItemID])
REFERENCES [dbo].[ItemServiceMaster] ([ItemID])
GO

ALTER TABLE [dbo].[PatientPrescription] CHECK CONSTRAINT [FK_PatientPrescription_ItemServiceMaster]
GO

ALTER TABLE [dbo].[PatientPrescription]  WITH CHECK ADD  CONSTRAINT [FK_PatientPrescription_LookupsMaster] FOREIGN KEY([Frequency])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientPrescription] CHECK CONSTRAINT [FK_PatientPrescription_LookupsMaster]
GO

ALTER TABLE [dbo].[PatientPrescription]  WITH CHECK ADD  CONSTRAINT [FK_PatientPrescription_PatientRegistration] FOREIGN KEY([PatientId])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
GO

ALTER TABLE [dbo].[PatientPrescription] CHECK CONSTRAINT [FK_PatientPrescription_PatientRegistration]
GO

ALTER TABLE [dbo].[PatientPrescription]  WITH CHECK ADD  CONSTRAINT [FK_PatientPrescription_PatientVisits] FOREIGN KEY([PatientId], [VisitID])
REFERENCES [dbo].[PatientVisits] ([PatientID], [VisitID])
GO

ALTER TABLE [dbo].[PatientPrescription] CHECK CONSTRAINT [FK_PatientPrescription_PatientVisits]
GO

ALTER TABLE [dbo].[PatientPrescription] ADD  CONSTRAINT [DF_PatientPrescription_Dosage]  DEFAULT ((0)) FOR [Dosage]
GO

ALTER TABLE [dbo].[PatientPrescription] ADD  CONSTRAINT [DF_PatientPrescription_Duaration]  DEFAULT ((0)) FOR [Duaration]
GO

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientExamFinding]    Script Date: 09/06/2014 00:29:21 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[PatientExamFinding](
	[PatientId] [bigint] NOT NULL,
	[ExamID] [smallint] NOT NULL,
	[VisitID] [smallint] NOT NULL,
	[FindCategory] [int] NOT NULL,
	[Findings] [int] NOT NULL,
 CONSTRAINT [PK_PatientExamFinding] PRIMARY KEY CLUSTERED 
(
	[PatientId] ASC,
	[ExamID] ASC,
	[VisitID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[PatientExamFinding]  WITH CHECK ADD  CONSTRAINT [FK_PatientExamFinding_Findings] FOREIGN KEY([Findings])
REFERENCES [dbo].[Findings] ([FindingID])
GO

ALTER TABLE [dbo].[PatientExamFinding] CHECK CONSTRAINT [FK_PatientExamFinding_Findings]
GO

ALTER TABLE [dbo].[PatientExamFinding]  WITH CHECK ADD  CONSTRAINT [FK_PatientExamFinding_LookupsMaster] FOREIGN KEY([FindCategory])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientExamFinding] CHECK CONSTRAINT [FK_PatientExamFinding_LookupsMaster]
GO

ALTER TABLE [dbo].[PatientExamFinding]  WITH CHECK ADD  CONSTRAINT [FK_PatientExamFinding_PatientRegistration] FOREIGN KEY([PatientId])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
GO

ALTER TABLE [dbo].[PatientExamFinding] CHECK CONSTRAINT [FK_PatientExamFinding_PatientRegistration]
GO

ALTER TABLE [dbo].[PatientExamFinding]  WITH CHECK ADD  CONSTRAINT [FK_PatientExamFinding_PatientVisits] FOREIGN KEY([PatientId], [VisitID])
REFERENCES [dbo].[PatientVisits] ([PatientID], [VisitID])
GO

ALTER TABLE [dbo].[PatientExamFinding] CHECK CONSTRAINT [FK_PatientExamFinding_PatientVisits]
GO




+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatienDiagnosis]    Script Date: 09/06/2014 00:29:28 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PatienDiagnosis](
	[PatientId] [bigint] NOT NULL,
	[PatienDiagnosisID] [smallint] NOT NULL,
	[VisitID] [smallint] NOT NULL,
	[DiagnosisID] [int] NOT NULL,
	[DiagnosisDate] [date] NULL,
	[Status] [varchar](100) NULL,
 CONSTRAINT [PK_PatienDiagnosis] PRIMARY KEY CLUSTERED 
(
	[PatientId] ASC,
	[PatienDiagnosisID] ASC,
	[VisitID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PatienDiagnosis]  WITH CHECK ADD  CONSTRAINT [FK_PatienDiagnosis_Diagnosis] FOREIGN KEY([DiagnosisID])
REFERENCES [dbo].[Diagnosis] ([DiagnosisID])
GO

ALTER TABLE [dbo].[PatienDiagnosis] CHECK CONSTRAINT [FK_PatienDiagnosis_Diagnosis]
GO

ALTER TABLE [dbo].[PatienDiagnosis]  WITH CHECK ADD  CONSTRAINT [FK_PatienDiagnosis_PatientRegistration] FOREIGN KEY([PatientId])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
GO

ALTER TABLE [dbo].[PatienDiagnosis] CHECK CONSTRAINT [FK_PatienDiagnosis_PatientRegistration]
GO

ALTER TABLE [dbo].[PatienDiagnosis]  WITH CHECK ADD  CONSTRAINT [FK_PatienDiagnosis_PatientVisits] FOREIGN KEY([PatientId], [VisitID])
REFERENCES [dbo].[PatientVisits] ([PatientID], [VisitID])
GO

ALTER TABLE [dbo].[PatienDiagnosis] CHECK CONSTRAINT [FK_PatienDiagnosis_PatientVisits]
GO

ALTER TABLE [dbo].[PatienDiagnosis] ADD  CONSTRAINT [DF_PatienDiagnosis_DiagnosisDate]  DEFAULT (getdate()) FOR [DiagnosisDate]
GO




+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientAppointment]    Script Date: 09/06/2014 00:29:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[PatientAppointment](
	[AppointmentID] [int] IDENTITY(1,1) NOT NULL,
	[PatientId] [bigint] NOT NULL,
	[ConsultationRoom] [int] NULL,
	[ConsultingDoc] [int] NOT NULL,
	[AppDataTime] [datetime] NOT NULL,
	[AppointmentType] [int] NOT NULL,
	[AppointmentStatus] [int] NULL,
	[AppConfirm] [bit] NULL,
	[AppTentative] [bit] NULL,
 CONSTRAINT [PK_PatientAppointment] PRIMARY KEY CLUSTERED 
(
	[AppointmentID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[PatientAppointment]  WITH CHECK ADD  CONSTRAINT [FK_PatientAppointment_DoctorMaster] FOREIGN KEY([ConsultingDoc])
REFERENCES [dbo].[DoctorMaster] ([DrID])
GO

ALTER TABLE [dbo].[PatientAppointment] CHECK CONSTRAINT [FK_PatientAppointment_DoctorMaster]
GO

ALTER TABLE [dbo].[PatientAppointment]  WITH CHECK ADD  CONSTRAINT [FK_PatientAppointment_LookupsMaster] FOREIGN KEY([AppointmentStatus])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientAppointment] CHECK CONSTRAINT [FK_PatientAppointment_LookupsMaster]
GO

ALTER TABLE [dbo].[PatientAppointment]  WITH CHECK ADD  CONSTRAINT [FK_PatientAppointment_LookupsMaster1] FOREIGN KEY([AppointmentType])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientAppointment] CHECK CONSTRAINT [FK_PatientAppointment_LookupsMaster1]
GO

ALTER TABLE [dbo].[PatientAppointment]  WITH CHECK ADD  CONSTRAINT [FK_PatientAppointment_PatientRegistration] FOREIGN KEY([PatientId])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
GO

ALTER TABLE [dbo].[PatientAppointment] CHECK CONSTRAINT [FK_PatientAppointment_PatientRegistration]
GO

ALTER TABLE [dbo].[PatientAppointment]  WITH CHECK ADD  CONSTRAINT [FK_PatientAppointment_RoomMaster] FOREIGN KEY([ConsultationRoom])
REFERENCES [dbo].[RoomMaster] ([RoomID])
GO

ALTER TABLE [dbo].[PatientAppointment] CHECK CONSTRAINT [FK_PatientAppointment_RoomMaster]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[Diagnosis]    Script Date: 09/06/2014 00:29:48 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Diagnosis](
	[DiagnosisID] [int] IDENTITY(1,1) NOT NULL,
	[Diagnosis] [varchar](500) NOT NULL,
	[ParentID] [int] NULL,
	[Remarks] [varchar](200) NULL,
 CONSTRAINT [PK_Diagnosis] PRIMARY KEY CLUSTERED 
(
	[DiagnosisID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Diagnosis]  WITH CHECK ADD  CONSTRAINT [FK_Diagnosis_Diagnosis] FOREIGN KEY([ParentID])
REFERENCES [dbo].[Diagnosis] ([DiagnosisID])
GO

ALTER TABLE [dbo].[Diagnosis] CHECK CONSTRAINT [FK_Diagnosis_Diagnosis]
GO




+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientRecall]    Script Date: 09/06/2014 00:29:57 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[PatientRecall](
	[RecallID] [int] IDENTITY(1,1) NOT NULL,
	[PatientId] [bigint] NOT NULL,
	[RecallDateTime] [date] NOT NULL,
	[RecallType] [int] NOT NULL,
	[RemindMe] [bit] NOT NULL,
	[RecallStatus] [int] NOT NULL,
	[ProcedureRecall] [int] NULL,
	[InvestigationRecall] [int] NULL,
	[RecallDr] [int] NOT NULL,
 CONSTRAINT [PK_PatientRecall] PRIMARY KEY CLUSTERED 
(
	[RecallID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[PatientRecall]  WITH CHECK ADD  CONSTRAINT [FK_PatientRecall_DoctorMaster] FOREIGN KEY([RecallDr])
REFERENCES [dbo].[DoctorMaster] ([DrID])
GO

ALTER TABLE [dbo].[PatientRecall] CHECK CONSTRAINT [FK_PatientRecall_DoctorMaster]
GO

ALTER TABLE [dbo].[PatientRecall]  WITH CHECK ADD  CONSTRAINT [FK_PatientRecall_Investigations] FOREIGN KEY([InvestigationRecall])
REFERENCES [dbo].[Investigations] ([InvestigationID])
GO

ALTER TABLE [dbo].[PatientRecall] CHECK CONSTRAINT [FK_PatientRecall_Investigations]
GO

ALTER TABLE [dbo].[PatientRecall]  WITH CHECK ADD  CONSTRAINT [FK_PatientRecall_LookupsMaster] FOREIGN KEY([RecallStatus])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientRecall] CHECK CONSTRAINT [FK_PatientRecall_LookupsMaster]
GO

ALTER TABLE [dbo].[PatientRecall]  WITH CHECK ADD  CONSTRAINT [FK_PatientRecall_LookupsMaster1] FOREIGN KEY([RecallType])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientRecall] CHECK CONSTRAINT [FK_PatientRecall_LookupsMaster1]
GO

ALTER TABLE [dbo].[PatientRecall]  WITH CHECK ADD  CONSTRAINT [FK_PatientRecall_PatientRegistration] FOREIGN KEY([PatientId])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
GO

ALTER TABLE [dbo].[PatientRecall] CHECK CONSTRAINT [FK_PatientRecall_PatientRegistration]
GO

ALTER TABLE [dbo].[PatientRecall]  WITH CHECK ADD  CONSTRAINT [FK_PatientRecall_TreatmentProcedures] FOREIGN KEY([ProcedureRecall])
REFERENCES [dbo].[TreatmentProcedures] ([ProcedureID])
GO

ALTER TABLE [dbo].[PatientRecall] CHECK CONSTRAINT [FK_PatientRecall_TreatmentProcedures]
GO

ALTER TABLE [dbo].[PatientRecall] ADD  CONSTRAINT [DF_PatientRecall_RemindMe]  DEFAULT ((0)) FOR [RemindMe]
GO




+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[Investigations]    Script Date: 09/06/2014 00:30:06 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Investigations](
	[InvestigationID] [int] IDENTITY(1,1) NOT NULL,
	[Investigation] [varchar](200) NOT NULL,
	[InvestigationCategory] [int] NOT NULL,
	[Remarks] [varchar](500) NULL,
 CONSTRAINT [PK_Investigations] PRIMARY KEY CLUSTERED 
(
	[InvestigationID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Investigations]  WITH CHECK ADD  CONSTRAINT [FK_Investigations_LookupsMaster] FOREIGN KEY([InvestigationCategory])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[Investigations] CHECK CONSTRAINT [FK_Investigations_LookupsMaster]
GO




+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[LookupsMaster]    Script Date: 09/06/2014 00:30:15 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[LookupsMaster](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) NOT NULL,
	[Type] [int] NOT NULL,
	[Rate] [float] NULL,
	[SystemDefined] [bit] NOT NULL,
	[Remarks] [varchar](200) NULL,
 CONSTRAINT [PK_LookupsMaster] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[LookupsMaster]  WITH CHECK ADD  CONSTRAINT [FK_LookupsMaster_LookupTypes] FOREIGN KEY([Type])
REFERENCES [dbo].[LookupTypes] ([LookupTypeID])
GO

ALTER TABLE [dbo].[LookupsMaster] CHECK CONSTRAINT [FK_LookupsMaster_LookupTypes]
GO

ALTER TABLE [dbo].[LookupsMaster] ADD  CONSTRAINT [DF_LookupsMaster_SystemDefined]  DEFAULT ((0)) FOR [SystemDefined]
GO




+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PrescriptionTempDetails]    Script Date: 09/06/2014 00:30:25 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PrescriptionTempDetails](
	[PrescriptionTempID] [int] NOT NULL,
	[PrescriptionTempDtlID] [smallint] NOT NULL,
	[MedicineItemID] [bigint] NOT NULL,
	[Dosage] [float] NOT NULL,
	[Frequency] [int] NULL,
	[Duaration] [float] NULL,
	[Periods] [varchar](20) NULL,
 CONSTRAINT [PK_PrescriptionTempDetails] PRIMARY KEY CLUSTERED 
(
	[PrescriptionTempID] ASC,
	[PrescriptionTempDtlID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PrescriptionTempDetails]  WITH CHECK ADD  CONSTRAINT [FK_PrescriptionTempDetails_ItemServiceMaster] FOREIGN KEY([MedicineItemID])
REFERENCES [dbo].[ItemServiceMaster] ([ItemID])
GO

ALTER TABLE [dbo].[PrescriptionTempDetails] CHECK CONSTRAINT [FK_PrescriptionTempDetails_ItemServiceMaster]
GO

ALTER TABLE [dbo].[PrescriptionTempDetails]  WITH CHECK ADD  CONSTRAINT [FK_PrescriptionTempDetails_LookupsMaster] FOREIGN KEY([Frequency])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PrescriptionTempDetails] CHECK CONSTRAINT [FK_PrescriptionTempDetails_LookupsMaster]
GO

ALTER TABLE [dbo].[PrescriptionTempDetails]  WITH CHECK ADD  CONSTRAINT [FK_PrescriptionTempDetails_PrescriptionTemplate] FOREIGN KEY([PrescriptionTempID])
REFERENCES [dbo].[PrescriptionTemplate] ([PrescriptionTempID])
GO

ALTER TABLE [dbo].[PrescriptionTempDetails] CHECK CONSTRAINT [FK_PrescriptionTempDetails_PrescriptionTemplate]
GO

ALTER TABLE [dbo].[PrescriptionTempDetails] ADD  CONSTRAINT [DF_PrescriptionTempDetails_Dosage]  DEFAULT ((0)) FOR [Dosage]
GO

ALTER TABLE [dbo].[PrescriptionTempDetails] ADD  CONSTRAINT [DF_PrescriptionTempDetails_Duaration]  DEFAULT ((0)) FOR [Duaration]
GO


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PrescriptionTemplate]    Script Date: 09/06/2014 00:31:09 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PrescriptionTemplate](
	[PrescriptionTempID] [int] IDENTITY(1,1) NOT NULL,
	[Prescription] [varchar](100) NOT NULL,
	[Remarks] [varchar](200) NULL,
 CONSTRAINT [PK_PrescriptionTemplate] PRIMARY KEY CLUSTERED 
(
	[PrescriptionTempID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO




+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[MedicineItemsDtl]    Script Date: 09/06/2014 00:31:21 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[MedicineItemsDtl](
	[ItemID] [bigint] NOT NULL,
	[Strenght] [varchar](50) NULL,
	[MedicineType] [int] NULL,
	[GenericDrug] [int] NULL,
	[Mfg] [int] NULL,
	[Composition] [varchar](100) NULL,
	[ShelfNo] [varchar](10) NULL,
	[RackNo] [varchar](10) NULL,
	[BoxNo] [varchar](10) NULL
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[MedicineItemsDtl]  WITH CHECK ADD  CONSTRAINT [FK_MedicineItemsDtl_ItemServiceMaster] FOREIGN KEY([ItemID])
REFERENCES [dbo].[ItemServiceMaster] ([ItemID])
GO

ALTER TABLE [dbo].[MedicineItemsDtl] CHECK CONSTRAINT [FK_MedicineItemsDtl_ItemServiceMaster]
GO

ALTER TABLE [dbo].[MedicineItemsDtl]  WITH CHECK ADD  CONSTRAINT [FK_MedicineItemsDtl_LookupsMaster] FOREIGN KEY([MedicineType])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[MedicineItemsDtl] CHECK CONSTRAINT [FK_MedicineItemsDtl_LookupsMaster]
GO

ALTER TABLE [dbo].[MedicineItemsDtl]  WITH CHECK ADD  CONSTRAINT [FK_MedicineItemsDtl_LookupsMaster1] FOREIGN KEY([GenericDrug])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[MedicineItemsDtl] CHECK CONSTRAINT [FK_MedicineItemsDtl_LookupsMaster1]
GO

ALTER TABLE [dbo].[MedicineItemsDtl]  WITH CHECK ADD  CONSTRAINT [FK_MedicineItemsDtl_LookupsMaster2] FOREIGN KEY([Mfg])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[MedicineItemsDtl] CHECK CONSTRAINT [FK_MedicineItemsDtl_LookupsMaster2]
GO




+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[ItemServiceMaster]    Script Date: 09/06/2014 00:31:30 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[ItemServiceMaster](
	[ItemID] [bigint] IDENTITY(1,1) NOT NULL,
	[ItemNo] [varchar](20) NOT NULL,
	[Name] [varchar](100) NOT NULL,
	[CategoryID] [smallint] NULL,
	[Rate] [float] NULL,
	[Unit] [int] NULL,
	[Remarks] [varchar](200) NULL,
	[IsInventoryItem] [bit] NOT NULL,
	[SubCategoryID] [smallint] NULL,
	[ROL] [numeric](10, 2) NULL,
 CONSTRAINT [PK_Items] PRIMARY KEY CLUSTERED 
(
	[ItemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[ItemServiceMaster] ADD  CONSTRAINT [DF_ItemServiceMaster_IsInventoryItem]  DEFAULT ((0)) FOR [IsInventoryItem]
GO




+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[Findings]    Script Date: 09/06/2014 00:31:38 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Findings](
	[FindingID] [int] IDENTITY(1,1) NOT NULL,
	[FindingCategory] [int] NOT NULL,
	[Finding] [varchar](200) NOT NULL,
 CONSTRAINT [PK_Findings] PRIMARY KEY CLUSTERED 
(
	[FindingID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Findings]  WITH CHECK ADD  CONSTRAINT [FK_Findings_LookupsMaster] FOREIGN KEY([FindingCategory])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[Findings] CHECK CONSTRAINT [FK_Findings_LookupsMaster]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientGeneralExminations]    Script Date: 09/06/2014 00:31:47 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PatientGeneralExminations](
	[PatientId] [bigint] NOT NULL,
	[ExamID] [smallint] NOT NULL,
	[ExamDate] [date] NOT NULL,
	[ExamByDr] [int] NOT NULL,
	[Pulse] [float] NULL,
	[Temperature] [float] NULL,
	[Respiration] [float] NULL,
	[BPUp] [float] NULL,
	[BPDown] [float] NULL,
	[HeartRate] [float] NULL,
	[Height] [numeric](4, 2) NULL,
	[Weight] [numeric](6, 2) NULL,
	[HealthStatus] [int] NOT NULL,
	[Notes] [varchar](500) NULL,
 CONSTRAINT [PK_PatientGeneralExminations] PRIMARY KEY CLUSTERED 
(
	[PatientId] ASC,
	[ExamID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PatientGeneralExminations]  WITH CHECK ADD  CONSTRAINT [FK_PatientGeneralExminations_DoctorMaster] FOREIGN KEY([ExamByDr])
REFERENCES [dbo].[DoctorMaster] ([DrID])
GO

ALTER TABLE [dbo].[PatientGeneralExminations] CHECK CONSTRAINT [FK_PatientGeneralExminations_DoctorMaster]
GO

ALTER TABLE [dbo].[PatientGeneralExminations]  WITH CHECK ADD  CONSTRAINT [FK_PatientGeneralExminations_LookupsMaster] FOREIGN KEY([HealthStatus])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientGeneralExminations] CHECK CONSTRAINT [FK_PatientGeneralExminations_LookupsMaster]
GO

ALTER TABLE [dbo].[PatientGeneralExminations]  WITH CHECK ADD  CONSTRAINT [FK_PatientGeneralExminations_PatientRegistration] FOREIGN KEY([PatientId])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
GO

ALTER TABLE [dbo].[PatientGeneralExminations] CHECK CONSTRAINT [FK_PatientGeneralExminations_PatientRegistration]
GO

ALTER TABLE [dbo].[PatientGeneralExminations] ADD  CONSTRAINT [DF_PatientGeneralExminations_Pulse]  DEFAULT ((0)) FOR [Pulse]
GO

ALTER TABLE [dbo].[PatientGeneralExminations] ADD  CONSTRAINT [DF_PatientGeneralExminations_Temperature]  DEFAULT ((0)) FOR [Temperature]
GO

ALTER TABLE [dbo].[PatientGeneralExminations] ADD  CONSTRAINT [DF_PatientGeneralExminations_Respiration]  DEFAULT ((0)) FOR [Respiration]
GO

ALTER TABLE [dbo].[PatientGeneralExminations] ADD  CONSTRAINT [DF_PatientGeneralExminations_BPUp]  DEFAULT ((0)) FOR [BPUp]
GO

ALTER TABLE [dbo].[PatientGeneralExminations] ADD  CONSTRAINT [DF_PatientGeneralExminations_BPDown]  DEFAULT ((0)) FOR [BPDown]
GO

ALTER TABLE [dbo].[PatientGeneralExminations] ADD  CONSTRAINT [DF_PatientGeneralExminations_HeartRate]  DEFAULT ((0)) FOR [HeartRate]
GO

ALTER TABLE [dbo].[PatientGeneralExminations] ADD  CONSTRAINT [DF_PatientGeneralExminations_Height]  DEFAULT ((0)) FOR [Height]
GO

ALTER TABLE [dbo].[PatientGeneralExminations] ADD  CONSTRAINT [DF_PatientGeneralExminations_Weight]  DEFAULT ((0)) FOR [Weight]
GO


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[Problems]    Script Date: 09/06/2014 00:32:04 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[Problems](
	[ProblemID] [int] IDENTITY(1,1) NOT NULL,
	[ProblemCategory] [int] NOT NULL,
	[Problem] [varchar](200) NOT NULL,
	[ChiefComplaint] [bit] NULL,
	[Remarks] [varchar](200) NULL,
 CONSTRAINT [PK_Problems] PRIMARY KEY CLUSTERED 
(
	[ProblemID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[Problems]  WITH CHECK ADD  CONSTRAINT [FK_Problems_LookupsMaster] FOREIGN KEY([ProblemCategory])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[Problems] CHECK CONSTRAINT [FK_Problems_LookupsMaster]
GO

ALTER TABLE [dbo].[Problems] ADD  CONSTRAINT [DF_Problems_ChiefComplaint]  DEFAULT ((0)) FOR [ChiefComplaint]
GO




+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[TreatmentProcedures]    Script Date: 09/06/2014 00:32:12 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[TreatmentProcedures](
	[ProcedureID] [int] IDENTITY(1,1) NOT NULL,
	[ProcedureDesc] [varchar](100) NOT NULL,
	[ProcedureCategory] [int] NOT NULL,
	[Remarks] [varchar](500) NULL,
 CONSTRAINT [PK_TreatmentProcedures] PRIMARY KEY CLUSTERED 
(
	[ProcedureID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[TreatmentProcedures]  WITH CHECK ADD  CONSTRAINT [FK_TreatmentProcedures_LookupsMaster] FOREIGN KEY([ProcedureCategory])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[TreatmentProcedures] CHECK CONSTRAINT [FK_TreatmentProcedures_LookupsMaster]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[LookupTypes]    Script Date: 09/06/2014 00:32:26 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[LookupTypes](
	[LookupTypeID] [int] IDENTITY(1,1) NOT NULL,
	[LookupType] [varchar](100) NOT NULL,
 CONSTRAINT [PK_LookupTypes] PRIMARY KEY CLUSTERED 
(
	[LookupTypeID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientFollowUp]    Script Date: 09/06/2014 00:32:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PatientFollowUp](
	[FollowUpID] [int] NOT NULL,
	[PatientId] [bigint] NOT NULL,
	[FollowupDate] [date] NOT NULL,
	[ContactType] [int] NOT NULL,
	[Remarks] [varchar](200) NULL,
	[RemindMe] [bit] NOT NULL,
 CONSTRAINT [PK_PatientFollowUp] PRIMARY KEY CLUSTERED 
(
	[FollowUpID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PatientFollowUp]  WITH CHECK ADD  CONSTRAINT [FK_PatientFollowUp_LookupsMaster] FOREIGN KEY([ContactType])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientFollowUp] CHECK CONSTRAINT [FK_PatientFollowUp_LookupsMaster]
GO

ALTER TABLE [dbo].[PatientFollowUp]  WITH CHECK ADD  CONSTRAINT [FK_PatientFollowUp_PatientRegistration] FOREIGN KEY([PatientId])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
GO

ALTER TABLE [dbo].[PatientFollowUp] CHECK CONSTRAINT [FK_PatientFollowUp_PatientRegistration]
GO

ALTER TABLE [dbo].[PatientFollowUp] ADD  CONSTRAINT [DF_PatientFollowUp_RemindMe]  DEFAULT ((0)) FOR [RemindMe]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientHabits]    Script Date: 09/06/2014 00:32:52 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[PatientHabits](
	[PatientID] [bigint] NOT NULL,
	[Habits] [int] NOT NULL
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[PatientHabits]  WITH CHECK ADD  CONSTRAINT [FK_PatientHabits_LookupsMaster] FOREIGN KEY([Habits])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientHabits] CHECK CONSTRAINT [FK_PatientHabits_LookupsMaster]
GO

ALTER TABLE [dbo].[PatientHabits]  WITH CHECK ADD  CONSTRAINT [FK_PatientHabits_PatientRegistration] FOREIGN KEY([PatientID])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
GO

ALTER TABLE [dbo].[PatientHabits] CHECK CONSTRAINT [FK_PatientHabits_PatientRegistration]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientImmunization]    Script Date: 09/06/2014 00:33:10 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[PatientImmunization](
	[PatientID] [bigint] NOT NULL,
	[Immunization] [int] NOT NULL
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[PatientImmunization]  WITH CHECK ADD  CONSTRAINT [FK_PatientImmunization_LookupsMaster] FOREIGN KEY([Immunization])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientImmunization] CHECK CONSTRAINT [FK_PatientImmunization_LookupsMaster]
GO

ALTER TABLE [dbo].[PatientImmunization]  WITH CHECK ADD  CONSTRAINT [FK_PatientImmunization_PatientRegistration] FOREIGN KEY([PatientID])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
GO

ALTER TABLE [dbo].[PatientImmunization] CHECK CONSTRAINT [FK_PatientImmunization_PatientRegistration]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientMedicalHistory]    Script Date: 09/06/2014 00:33:17 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PatientMedicalHistory](
	[PatienHistorytId] [bigint] NOT NULL,
	[PatientId] [bigint] NOT NULL,
	[Diseases] [varchar](200) NOT NULL,
	[HappendWhen] [varchar](50) NULL,
	[Treatments] [varchar](500) NULL,
	[Notes] [varchar](200) NULL,
 CONSTRAINT [PK_PatientMedicalHistory] PRIMARY KEY CLUSTERED 
(
	[PatienHistorytId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PatientMedicalHistory]  WITH CHECK ADD  CONSTRAINT [FK_PatientMedicalHistory_PatientRegistration] FOREIGN KEY([PatientId])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
GO

ALTER TABLE [dbo].[PatientMedicalHistory] CHECK CONSTRAINT [FK_PatientMedicalHistory_PatientRegistration]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[BillTemplates]    Script Date: 09/06/2014 00:33:28 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[BillTemplates](
	[BillTemplateID] [smallint] IDENTITY(1,1) NOT NULL,
	[TemplateName] [varchar](100) NOT NULL,
	[Remarks] [varchar](500) NULL,
	[CreatedBy] [int] NOT NULL,
	[CreatedDateTime] [date] NOT NULL,
	[UpdatedBy] [int] NULL,
	[UpdatedDateTime] [date] NULL,
 CONSTRAINT [PK_BillTemplates] PRIMARY KEY CLUSTERED 
(
	[BillTemplateID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[BillTemplates] ADD  CONSTRAINT [DF_BillTemplates_CreatedDateTime]  DEFAULT (getdate()) FOR [CreatedDateTime]
GO


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[BillTemplateDetails]    Script Date: 09/06/2014 00:33:46 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[BillTemplateDetails](
	[BillTemplateDtlID] [int] IDENTITY(1,1) NOT NULL,
	[BillTemplateID] [smallint] NOT NULL,
	[ItemID] [bigint] NOT NULL,
	[ItemOrderNo] [smallint] NOT NULL,
 CONSTRAINT [PK_BillTemplateDetails] PRIMARY KEY CLUSTERED 
(
	[BillTemplateDtlID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[BillTemplateDetails] ADD  CONSTRAINT [DF_BillTemplateDetails_ItemOrderNo]  DEFAULT ((0)) FOR [ItemOrderNo]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PurchaseOrder]    Script Date: 09/06/2014 00:33:55 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PurchaseOrder](
	[OrderNo] [int] IDENTITY(1,1) NOT NULL,
	[VendorID] [int] NOT NULL,
	[OrdDate] [date] NOT NULL,
	[Remarks] [varchar](500) NULL,
	[GrossAmt] [float] NOT NULL,
	[TaxDisc] [float] NOT NULL,
	[NetAmt] [float] NOT NULL,
	[CreatedBy] [int] NOT NULL,
	[CreatedDateTime] [date] NOT NULL,
	[UpdatedBy] [int] NULL,
	[UpdatedDateTime] [date] NULL,
 CONSTRAINT [PK_tbl_PurchaseOrder] PRIMARY KEY CLUSTERED 
(
	[OrderNo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PurchaseOrder]  WITH CHECK ADD  CONSTRAINT [FK_PurchaseOrder_SupplierMaster] FOREIGN KEY([VendorID])
REFERENCES [dbo].[SupplierMaster] ([SupplierID])
GO

ALTER TABLE [dbo].[PurchaseOrder] CHECK CONSTRAINT [FK_PurchaseOrder_SupplierMaster]
GO

ALTER TABLE [dbo].[PurchaseOrder] ADD  CONSTRAINT [DF_PurchaseOrder_CreatedDateTime]  DEFAULT (getdate()) FOR [CreatedDateTime]
GO


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PurchaseMaster]    Script Date: 09/06/2014 00:34:06 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PurchaseMaster](
	[InvoiceID] [bigint] IDENTITY(1,1) NOT NULL,
	[InvoiceNo] [varchar](50) NOT NULL,
	[VendorID] [int] NOT NULL,
	[InvDate] [date] NOT NULL,
	[Remarks] [varchar](500) NULL,
	[GrossAmt] [float] NOT NULL,
	[TaxDisc] [float] NOT NULL,
	[NetAmt] [float] NOT NULL,
	[CreatedBy] [int] NOT NULL,
	[CreatedDateTime] [date] NOT NULL,
	[UpdatedBy] [int] NULL,
	[UpdatedDateTime] [date] NULL,
 CONSTRAINT [PK_tbl_Purchase] PRIMARY KEY CLUSTERED 
(
	[InvoiceID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PurchaseMaster]  WITH CHECK ADD  CONSTRAINT [FK_PurchaseMaster_SupplierMaster] FOREIGN KEY([VendorID])
REFERENCES [dbo].[SupplierMaster] ([SupplierID])
GO

ALTER TABLE [dbo].[PurchaseMaster] CHECK CONSTRAINT [FK_PurchaseMaster_SupplierMaster]
GO

ALTER TABLE [dbo].[PurchaseMaster] ADD  CONSTRAINT [DF_PurchaseMaster_CreatedDateTime]  DEFAULT (getdate()) FOR [CreatedDateTime]
GO


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PurchaseTaxDiscDtl]    Script Date: 09/06/2014 00:34:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[PurchaseTaxDiscDtl](
	[InvoiceID] [bigint] NOT NULL,
	[Charges] [int] NOT NULL,
	[Rate] [float] NULL,
	[TotalAmt] [float] NULL
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[PurchaseTaxDiscDtl]  WITH CHECK ADD  CONSTRAINT [FK_PurchaseTaxDiscDtl_LookupsMaster] FOREIGN KEY([Charges])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PurchaseTaxDiscDtl] CHECK CONSTRAINT [FK_PurchaseTaxDiscDtl_LookupsMaster]
GO

ALTER TABLE [dbo].[PurchaseTaxDiscDtl]  WITH CHECK ADD  CONSTRAINT [FK_PurchaseTaxDiscDtl_PurchaseMaster] FOREIGN KEY([InvoiceID])
REFERENCES [dbo].[PurchaseMaster] ([InvoiceID])
GO

ALTER TABLE [dbo].[PurchaseTaxDiscDtl] CHECK CONSTRAINT [FK_PurchaseTaxDiscDtl_PurchaseMaster]
GO

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PurchaseDetails]    Script Date: 09/06/2014 00:34:30 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PurchaseDetails](
	[InvoiceID] [bigint] NOT NULL,
	[ItemID] [bigint] NOT NULL,
	[Qty] [float] NOT NULL,
	[Unit] [int] NOT NULL,
	[Rate] [float] NOT NULL,
	[TotalAmt] [float] NOT NULL,
	[ItemDesc] [varchar](50) NULL,
	[BatchNoFrom] [varchar](50) NULL,
	[SrNoUpto] [int] NULL,
	[ItemNo] [smallint] NULL
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PurchaseDetails]  WITH CHECK ADD  CONSTRAINT [FK_PurchaseDetails_ItemServiceMaster] FOREIGN KEY([ItemID])
REFERENCES [dbo].[ItemServiceMaster] ([ItemID])
GO

ALTER TABLE [dbo].[PurchaseDetails] CHECK CONSTRAINT [FK_PurchaseDetails_ItemServiceMaster]
GO

ALTER TABLE [dbo].[PurchaseDetails]  WITH CHECK ADD  CONSTRAINT [FK_PurchaseDetails_PurchaseMaster] FOREIGN KEY([InvoiceID])
REFERENCES [dbo].[PurchaseMaster] ([InvoiceID])
GO

ALTER TABLE [dbo].[PurchaseDetails] CHECK CONSTRAINT [FK_PurchaseDetails_PurchaseMaster]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientPayDetails]    Script Date: 09/06/2014 00:34:42 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[PatientPayDetails](
	[PatientID] [bigint] NOT NULL,
	[PayID] [bigint] NOT NULL,
	[ReceivedBy] [int] NOT NULL,
	[ReceivedDataTime] [date] NOT NULL,
 CONSTRAINT [PK_PatientPayDetails_1] PRIMARY KEY CLUSTERED 
(
	[PatientID] ASC,
	[PayID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[PatientPayDetails] ADD  CONSTRAINT [DF_PatientPayDetails_ReceivedDataTime]  DEFAULT (getdate()) FOR [ReceivedDataTime]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


USE [HMSIndia]
GO

/****** Object:  Table [dbo].[BillPayDetails]    Script Date: 09/06/2014 00:34:53 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[BillPayDetails](
	[BillPayID] [bigint] IDENTITY(1,1) NOT NULL,
	[BillID] [bigint] NULL,
	[PayMode] [int] NOT NULL,
	[Cheque_CC_No] [varchar](20) NULL,
	[ChequeDate] [date] NULL,
	[BankID] [int] NULL,
	[Amount] [numeric](18, 2) NOT NULL,
	[ReceivedDate] [date] NULL,
 CONSTRAINT [PK_BillPayDetails] PRIMARY KEY CLUSTERED 
(
	[BillPayID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[BillPayDetails]  WITH CHECK ADD  CONSTRAINT [FK_BillPayDetails_BankMaster] FOREIGN KEY([BankID])
REFERENCES [dbo].[BankMaster] ([BankID])
GO

ALTER TABLE [dbo].[BillPayDetails] CHECK CONSTRAINT [FK_BillPayDetails_BankMaster]
GO

ALTER TABLE [dbo].[BillPayDetails]  WITH CHECK ADD  CONSTRAINT [FK_BillPayDetails_BillingMaster] FOREIGN KEY([BillID])
REFERENCES [dbo].[BillingMaster] ([BillID])
GO

ALTER TABLE [dbo].[BillPayDetails] CHECK CONSTRAINT [FK_BillPayDetails_BillingMaster]
GO

ALTER TABLE [dbo].[BillPayDetails]  WITH CHECK ADD  CONSTRAINT [FK_BillPayDetails_LookupsMaster] FOREIGN KEY([PayMode])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[BillPayDetails] CHECK CONSTRAINT [FK_BillPayDetails_LookupsMaster]
GO

ALTER TABLE [dbo].[BillPayDetails] ADD  CONSTRAINT [DF_BillPayDetails_Amount]  DEFAULT ((0)) FOR [Amount]
GO

ALTER TABLE [dbo].[BillPayDetails] ADD  CONSTRAINT [DF_BillPayDetails_ReceivedDate]  DEFAULT (getdate()) FOR [ReceivedDate]
GO


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[UserProfile]    Script Date: 09/06/2014 00:35:14 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[UserProfile](
	[ProfileID] [smallint] IDENTITY(1,1) NOT NULL,
	[ProfileName] [varchar](100) NOT NULL,
	[CreatedateTime] [datetime] NOT NULL,
 CONSTRAINT [PK_UserProfile] PRIMARY KEY CLUSTERED 
(
	[ProfileID] ASC,
	[ProfileName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[UserProfile] ADD  CONSTRAINT [DF_UserProfile_CreatedateTime]  DEFAULT (getdate()) FOR [CreatedateTime]
GO


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[ModulePermissions]    Script Date: 09/06/2014 00:35:37 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[ModulePermissions](
	[ModuleID] [int] NOT NULL,
	[ProfileID] [int] NOT NULL,
	[PAdd] [bit] NOT NULL,
	[PEdit] [bit] NOT NULL,
	[PDelete] [bit] NOT NULL,
	[PView] [bit] NOT NULL,
	[PPrint] [bit] NOT NULL,
 CONSTRAINT [PK_ModulePermissions] PRIMARY KEY CLUSTERED 
(
	[ModuleID] ASC,
	[ProfileID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[ModulePermissions] ADD  CONSTRAINT [DF_ModulePermissions_PAdd]  DEFAULT ((0)) FOR [PAdd]
GO

ALTER TABLE [dbo].[ModulePermissions] ADD  CONSTRAINT [DF_ModulePermissions_PEdit]  DEFAULT ((0)) FOR [PEdit]
GO

ALTER TABLE [dbo].[ModulePermissions] ADD  CONSTRAINT [DF_ModulePermissions_PDelete]  DEFAULT ((0)) FOR [PDelete]
GO

ALTER TABLE [dbo].[ModulePermissions] ADD  CONSTRAINT [DF_ModulePermissions_PView]  DEFAULT ((0)) FOR [PView]
GO

ALTER TABLE [dbo].[ModulePermissions] ADD  CONSTRAINT [DF_ModulePermissions_PPrint]  DEFAULT ((0)) FOR [PPrint]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[ModuleList]    Script Date: 09/06/2014 00:35:45 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[ModuleList](
	[ModuleID] [int] IDENTITY(1,1) NOT NULL,
	[ModuleName] [varchar](50) NOT NULL,
	[ModuleType] [varchar](50) NOT NULL,
 CONSTRAINT [PK_ModuleList] PRIMARY KEY CLUSTERED 
(
	[ModuleID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientAddmissionInfo]    Script Date: 09/06/2014 00:35:55 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PatientAddmissionInfo](
	[PatientAdmissionID] [bigint] IDENTITY(1,1) NOT NULL,
	[PatientID] [bigint] NOT NULL,
	[AdminssionDate] [date] NOT NULL,
	[WardID] [int] NULL,
	[DeptID] [int] NULL,
	[RoomNo] [int] NULL,
	[Diseases] [varchar](500) NULL,
	[Remarks] [varchar](200) NULL,
 CONSTRAINT [PK_PatientAddmissionInfo] PRIMARY KEY CLUSTERED 
(
	[PatientAdmissionID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PatientAddmissionInfo]  WITH CHECK ADD  CONSTRAINT [FK_PatientAddmissionInfo_DepartmentMaster] FOREIGN KEY([DeptID])
REFERENCES [dbo].[DepartmentMaster] ([DeptID])
GO

ALTER TABLE [dbo].[PatientAddmissionInfo] CHECK CONSTRAINT [FK_PatientAddmissionInfo_DepartmentMaster]
GO

ALTER TABLE [dbo].[PatientAddmissionInfo]  WITH CHECK ADD  CONSTRAINT [FK_PatientAddmissionInfo_PatientRegistration] FOREIGN KEY([PatientID])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
GO

ALTER TABLE [dbo].[PatientAddmissionInfo] CHECK CONSTRAINT [FK_PatientAddmissionInfo_PatientRegistration]
GO

ALTER TABLE [dbo].[PatientAddmissionInfo]  WITH CHECK ADD  CONSTRAINT [FK_PatientAddmissionInfo_RoomMaster] FOREIGN KEY([RoomNo])
REFERENCES [dbo].[RoomMaster] ([RoomID])
GO

ALTER TABLE [dbo].[PatientAddmissionInfo] CHECK CONSTRAINT [FK_PatientAddmissionInfo_RoomMaster]
GO

ALTER TABLE [dbo].[PatientAddmissionInfo]  WITH CHECK ADD  CONSTRAINT [FK_PatientAddmissionInfo_WardMaster] FOREIGN KEY([WardID])
REFERENCES [dbo].[WardMaster] ([WardID])
GO

ALTER TABLE [dbo].[PatientAddmissionInfo] CHECK CONSTRAINT [FK_PatientAddmissionInfo_WardMaster]
GO


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[DoctorMaster]    Script Date: 09/06/2014 00:36:04 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[DoctorMaster](
	[DrID] [int] IDENTITY(1,1) NOT NULL,
	[FirstName] [varchar](100) NOT NULL,
	[LastName] [varchar](100) NULL,
	[SurName] [varchar](50) NULL,
	[Address] [varchar](200) NULL,
	[TelephoneNo] [varchar](50) NULL,
	[MobileNo] [varchar](30) NULL,
	[Gender] [bit] NOT NULL,
	[Age] [numeric](5, 2) NULL,
	[LicenseNo] [varchar](50) NOT NULL,
	[Specialization] [int] NULL,
	[DrType] [int] NULL,
	[ConsultationCharge] [int] NULL,
 CONSTRAINT [PK_DoctorMaster] PRIMARY KEY CLUSTERED 
(
	[DrID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[DoctorMaster] ADD  CONSTRAINT [DF_DoctorMaster_Gender]  DEFAULT ((1)) FOR [Gender]
GO

ALTER TABLE [dbo].[DoctorMaster] ADD  CONSTRAINT [DF_DoctorMaster_ConsultationCharge]  DEFAULT ((0)) FOR [ConsultationCharge]
GO




+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[EmpMaster]    Script Date: 09/06/2014 00:36:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[EmpMaster](
	[EmpID] [int] IDENTITY(1,1) NOT NULL,
	[EmpNo] [varchar](50) NOT NULL,
	[FirstName] [varchar](100) NOT NULL,
	[LastName] [varchar](100) NULL,
	[SurName] [varchar](50) NULL,
	[Address] [varchar](200) NULL,
	[Telephone No] [varchar](50) NULL,
	[Mobile No] [varchar](30) NULL,
	[EmpType] [int] NULL,
	[Gender] [bit] NOT NULL,
	[Age] [numeric](5, 2) NULL,
 CONSTRAINT [PK_EmpMaster] PRIMARY KEY CLUSTERED 
(
	[EmpID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'1-Male, 0-Female' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'EmpMaster', @level2type=N'COLUMN',@level2name=N'Gender'
GO

ALTER TABLE [dbo].[EmpMaster] ADD  CONSTRAINT [DF_EmpMaster_Gender]  DEFAULT ((1)) FOR [Gender]
GO

ALTER TABLE [dbo].[EmpMaster] ADD  CONSTRAINT [DF_EmpMaster_Age]  DEFAULT ((0)) FOR [Age]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[DepartmentMaster]    Script Date: 09/06/2014 00:36:33 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[DepartmentMaster](
	[DeptID] [int] IDENTITY(1,1) NOT NULL,
	[DeptName] [varchar](50) NOT NULL,
	[Charges] [int] NULL,
	[Incharge] [int] NULL,
	[Remarks] [varchar](200) NULL,
 CONSTRAINT [PK_DepartmentMaster] PRIMARY KEY CLUSTERED 
(
	[DeptID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[DepartmentMaster] ADD  CONSTRAINT [DF_DepartmentMaster_Charges]  DEFAULT ((0)) FOR [Charges]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
USE [HMSIndia]
GO

/****** Object:  Table [dbo].[RoomMaster]    Script Date: 09/06/2014 00:36:47 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[RoomMaster](
	[RoomID] [int] IDENTITY(1,1) NOT NULL,
	[RoomNo] [varchar](50) NOT NULL,
	[DeptID] [int] NULL,
	[WardID] [int] NULL,
	[RoomCost] [int] NULL,
	[Remarks] [varchar](200) NULL,
	[RoomType] [int] NULL,
 CONSTRAINT [PK_RoomMaster] PRIMARY KEY CLUSTERED 
(
	[RoomID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[RoomMaster]  WITH CHECK ADD  CONSTRAINT [FK_RoomMaster_DepartmentMaster] FOREIGN KEY([DeptID])
REFERENCES [dbo].[DepartmentMaster] ([DeptID])
GO

ALTER TABLE [dbo].[RoomMaster] CHECK CONSTRAINT [FK_RoomMaster_DepartmentMaster]
GO

ALTER TABLE [dbo].[RoomMaster]  WITH CHECK ADD  CONSTRAINT [FK_RoomMaster_LookupsMaster] FOREIGN KEY([RoomType])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[RoomMaster] CHECK CONSTRAINT [FK_RoomMaster_LookupsMaster]
GO

ALTER TABLE [dbo].[RoomMaster]  WITH CHECK ADD  CONSTRAINT [FK_RoomMaster_WardMaster] FOREIGN KEY([WardID])
REFERENCES [dbo].[WardMaster] ([WardID])
GO

ALTER TABLE [dbo].[RoomMaster] CHECK CONSTRAINT [FK_RoomMaster_WardMaster]
GO

ALTER TABLE [dbo].[RoomMaster] ADD  CONSTRAINT [DF_RoomMaster_RoomCost]  DEFAULT ((0)) FOR [RoomCost]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
USE [HMSIndia]
GO

/****** Object:  Table [dbo].[WardMaster]    Script Date: 09/06/2014 00:37:04 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[WardMaster](
	[WardID] [int] IDENTITY(1,1) NOT NULL,
	[WardNo] [varchar](50) NOT NULL,
	[DeptID] [int] NOT NULL,
	[Remarks] [varchar](200) NULL,
 CONSTRAINT [PK_WardMaster] PRIMARY KEY CLUSTERED 
(
	[WardID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[WardMaster]  WITH CHECK ADD  CONSTRAINT [FK_WardMaster_DepartmentMaster] FOREIGN KEY([DeptID])
REFERENCES [dbo].[DepartmentMaster] ([DeptID])
GO

ALTER TABLE [dbo].[WardMaster] CHECK CONSTRAINT [FK_WardMaster_DepartmentMaster]
GO


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[DiseasesMaster]    Script Date: 09/06/2014 00:37:14 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[DiseasesMaster](
	[DID] [int] IDENTITY(1,1) NOT NULL,
	[Diseases] [varchar](1000) NOT NULL,
 CONSTRAINT [PK_DiseasesMaster] PRIMARY KEY CLUSTERED 
(
	[DID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PatientGuardians]    Script Date: 09/06/2014 00:37:24 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PatientGuardians](
	[PatientID] [bigint] NOT NULL,
	[GuardianName] [varchar](50) NOT NULL,
	[Relationship] [int] NOT NULL,
	[ContactNo] [varchar](50) NULL,
	[HealthStatus] [int] NULL,
	[Age] [numeric](5, 2) NULL,
	[Diseases] [varchar](200) NULL,
	[Notes] [varchar](200) NULL
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PatientGuardians]  WITH CHECK ADD  CONSTRAINT [FK_PatientGuardians_LookupsMaster] FOREIGN KEY([Relationship])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientGuardians] CHECK CONSTRAINT [FK_PatientGuardians_LookupsMaster]
GO

ALTER TABLE [dbo].[PatientGuardians]  WITH CHECK ADD  CONSTRAINT [FK_PatientGuardians_LookupsMaster1] FOREIGN KEY([HealthStatus])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PatientGuardians] CHECK CONSTRAINT [FK_PatientGuardians_LookupsMaster1]
GO

ALTER TABLE [dbo].[PatientGuardians]  WITH CHECK ADD  CONSTRAINT [FK_PatientGuardians_PatientRegistration] FOREIGN KEY([PatientID])
REFERENCES [dbo].[PatientRegistration] ([PatientId])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[PatientGuardians] CHECK CONSTRAINT [FK_PatientGuardians_PatientRegistration]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PurchaseOrderDtl]    Script Date: 09/06/2014 00:37:34 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[PurchaseOrderDtl](
	[OrderNo] [int] NOT NULL,
	[ItemID] [bigint] NOT NULL,
	[Qty] [float] NOT NULL,
	[Unit] [int] NOT NULL,
	[Rate] [float] NOT NULL,
	[TotalAmt] [float] NOT NULL,
	[ItemDesc] [varchar](50) NULL,
	[ItemNo] [smallint] NULL
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[PurchaseOrderDtl]  WITH CHECK ADD  CONSTRAINT [FK_PurchaseOrderDtl_ItemServiceMaster] FOREIGN KEY([ItemID])
REFERENCES [dbo].[ItemServiceMaster] ([ItemID])
GO

ALTER TABLE [dbo].[PurchaseOrderDtl] CHECK CONSTRAINT [FK_PurchaseOrderDtl_ItemServiceMaster]
GO

ALTER TABLE [dbo].[PurchaseOrderDtl]  WITH CHECK ADD  CONSTRAINT [FK_PurchaseOrderDtl_PurchaseOrder] FOREIGN KEY([OrderNo])
REFERENCES [dbo].[PurchaseOrder] ([OrderNo])
GO

ALTER TABLE [dbo].[PurchaseOrderDtl] CHECK CONSTRAINT [FK_PurchaseOrderDtl_PurchaseOrder]
GO


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


USE [HMSIndia]
GO

/****** Object:  Table [dbo].[BillingCharges]    Script Date: 09/06/2014 00:37:43 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[BillingCharges](
	[BillID] [bigint] NOT NULL,
	[Charges] [int] NOT NULL,
	[Rate] [float] NULL,
	[TotalAmt] [float] NULL
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[BillingCharges]  WITH CHECK ADD  CONSTRAINT [FK_BillingCharges_BillingMaster] FOREIGN KEY([BillID])
REFERENCES [dbo].[BillingMaster] ([BillID])
ON DELETE CASCADE
GO

ALTER TABLE [dbo].[BillingCharges] CHECK CONSTRAINT [FK_BillingCharges_BillingMaster]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[BillingDetails]    Script Date: 09/06/2014 00:37:53 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[BillingDetails](
	[BillID] [bigint] NOT NULL,
	[ItemID] [int] NOT NULL,
	[Qty] [float] NOT NULL,
	[Unit] [int] NOT NULL,
	[Rate] [float] NOT NULL,
	[TotalAmt] [float] NOT NULL,
	[ItemDesc] [varchar](100) NULL,
	[BatchNo] [varchar](50) NULL,
	[ItemNo] [smallint] NULL
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[BillingDetails]  WITH CHECK ADD  CONSTRAINT [FK_BillingDetails_BillingMaster] FOREIGN KEY([BillID])
REFERENCES [dbo].[BillingMaster] ([BillID])
GO

ALTER TABLE [dbo].[BillingDetails] CHECK CONSTRAINT [FK_BillingDetails_BillingMaster]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[SecurityMaster]    Script Date: 09/06/2014 00:38:11 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[SecurityMaster](
	[UserId] [smallint] IDENTITY(1,1) NOT NULL,
	[UserName] [varchar](50) NOT NULL,
	[Password] [varchar](100) NOT NULL,
	[CreatedBy] [smallint] NOT NULL,
	[CreatedDatetime] [datetime] NOT NULL,
	[IsSuperUser] [bit] NULL,
	[IsLocked] [bit] NULL,
	[Last_Login_Date_Time] [datetime] NULL,
	[PassQuestion] [varchar](100) NULL,
	[PassAns] [varchar](50) NULL,
	[ProfileID] [smallint] NULL,
 CONSTRAINT [PK_SecurityMaster] PRIMARY KEY CLUSTERED 
(
	[UserId] ASC,
	[UserName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[SecurityMaster] ADD  CONSTRAINT [DF_SecurityMaster_CreatedBy]  DEFAULT ((1)) FOR [CreatedBy]
GO

ALTER TABLE [dbo].[SecurityMaster] ADD  CONSTRAINT [DF_SecurityMaster_CreatedDatetime]  DEFAULT (getdate()) FOR [CreatedDatetime]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[SupplierMaster]    Script Date: 09/06/2014 00:38:22 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING OFF
GO

CREATE TABLE [dbo].[SupplierMaster](
	[SupplierID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](100) NOT NULL,
	[Address] [varchar](200) NULL,
	[Address1] [varchar](200) NULL,
	[Telephone No] [varchar](50) NULL,
	[Mobile No] [varchar](30) NULL,
	[Contact Person] [varchar](50) NULL,
	[Email] [varchar](30) NULL,
	[CreditLimit] [float] NULL,
	[CreditPeriod] [smallint] NULL,
 CONSTRAINT [PK_tbl_Supplier] PRIMARY KEY CLUSTERED 
(
	[SupplierID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[PurchaseOrderTaxDiscDtl]    Script Date: 09/06/2014 00:38:32 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[PurchaseOrderTaxDiscDtl](
	[OrderNo] [int] NOT NULL,
	[Charges] [int] NOT NULL,
	[Rate] [float] NULL,
	[TotalAmt] [float] NULL
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[PurchaseOrderTaxDiscDtl]  WITH CHECK ADD  CONSTRAINT [FK_PurchaseOrderTaxDiscDtl_LookupsMaster] FOREIGN KEY([Charges])
REFERENCES [dbo].[LookupsMaster] ([ID])
GO

ALTER TABLE [dbo].[PurchaseOrderTaxDiscDtl] CHECK CONSTRAINT [FK_PurchaseOrderTaxDiscDtl_LookupsMaster]
GO

ALTER TABLE [dbo].[PurchaseOrderTaxDiscDtl]  WITH CHECK ADD  CONSTRAINT [FK_PurchaseOrderTaxDiscDtl_PurchaseOrder] FOREIGN KEY([OrderNo])
REFERENCES [dbo].[PurchaseOrder] ([OrderNo])
GO

ALTER TABLE [dbo].[PurchaseOrderTaxDiscDtl] CHECK CONSTRAINT [FK_PurchaseOrderTaxDiscDtl_PurchaseOrder]
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[CompanyMaster]    Script Date: 09/06/2014 00:38:43 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[CompanyMaster](
	[Company Id] [int] IDENTITY(1,1) NOT NULL,
	[Company Name] [varchar](100) NOT NULL,
	[Address_Office] [varchar](200) NULL,
	[Telephone No] [varchar](50) NULL,
	[Description] [varchar](200) NULL,
	[Tin VAT] [varchar](50) NULL,
	[Tin CST] [varchar](50) NULL,
	[InvoiceTerm] [varchar](1000) NULL,
	[ItemNoAuto] [bit] NULL,
	[BillPrefix] [varchar](6) NULL,
	[BillCrNo] [bigint] NULL,
	[BillSufix] [varchar](6) NULL,
 CONSTRAINT [PK_Company] PRIMARY KEY CLUSTERED 
(
	[Company Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO



+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

USE [HMSIndia]
GO

/****** Object:  Table [dbo].[BankMaster]    Script Date: 09/06/2014 00:38:54 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING OFF
GO

CREATE TABLE [dbo].[BankMaster](
	[BankID] [int] IDENTITY(1,1) NOT NULL,
	[BankName] [varchar](100) NOT NULL
) ON [PRIMARY]
SET ANSI_PADDING ON
ALTER TABLE [dbo].[BankMaster] ADD [BranchName] [varchar](100) NULL
ALTER TABLE [dbo].[BankMaster] ADD [Address] [varchar](200) NULL
ALTER TABLE [dbo].[BankMaster] ADD [TelNo] [varchar](50) NULL
/****** Object:  Index [PK_BankMaster]    Script Date: 09/06/2014 00:38:54 ******/
ALTER TABLE [dbo].[BankMaster] ADD  CONSTRAINT [PK_BankMaster] PRIMARY KEY CLUSTERED 
(
	[BankID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

